package com.cskaoyan.javase.oop1._3memory;

/**
 * 创建两个对象,然后声明一个引用指向某个对象
 *
 * @since 14:40
 * @author wuguidong@cskaoyan.onaliyun.com
 */
public class Demo2 {
    public static void main(String[] args) {
        Cat c1 = new Cat();
        Cat c2 = new Cat();
        // c3和c1两个引用指向同一对象,如果使用某个引用操作对象,那么用另外一个引用访问会看到变化
        Cat c3 = c1;
        c1.color = '白';
        System.out.println(c1.color);
        // false
        System.out.println(c1 == c2);
        // true
        System.out.println(c1 == c3);
    }
}

class Cat {
    double price;
    String breed;
    char color;

    public void catchMouse() {
        System.out.println("我会抓老鼠!");
    }
}
